﻿@page "/vardeftable"
@attribute [TabItemOption(Text = "变量定义列表")]

@using BootstrapBlazor.Components
@using TrackSystem.Entities.Dtos.Var


<PageTitle>变量定义列表</PageTitle>

<Table TItem="VarDto"
       AutoGenerateColumns="true"
       class="table-demo"
       RenderMode="TableRenderMode.Auto"
       IsPagination="true"
       PageItemsSource="@PageItemsSource"
       IsExcel="@IsExeclMode"
       IsStriped="true"
       IsBordered="true"
       IsMultipleSelect="true"
       ShowSkeleton="true"
       ShowToolbar="true"
       ShowLoading="true"
       ShowSearch="true"
       ShowExtendButtons="true"
       ShowExportButton="true"
       ShowExportPdfButton="true"
       OnQueryAsync="OnQueryAsync"
       OnSaveAsync="OnSaveAsync"
       OnDeleteAsync="OnDeleteAsync">

    <TableColumns>
        <TableColumn @bind-Field="@context.Id" Readonly="true" />
        <TableColumn @bind-Field="@context.Serial" Readonly="true" />
        <TableColumn @bind-Field="@context.snrloopId" Readonly="true" />
    </TableColumns>

    <EditTemplate>
        <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.Name"  maxlength="20"></BootstrapInput>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.Description" maxlength="50"></BootstrapInput>
            </div>
            <div class="col-12 col-sm-6">
                <Dropdown @bind-Value="@context.Serial" Placeholder="变量类型" Items="@_varSerialItem"></Dropdown>
            </div>
            <div class="col-12 col-sm-6">
                <Switch @bind-Value="@context.ReadOnly" Placeholder="读写属性" OnText="只读" OffText="读写"></Switch>
            </div>
            <div class="col-12 col-sm-6">
                <Dropdown @bind-Value="@context.DataType" Placeholder="数据类型"></Dropdown>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.InitValue" Placeholder="初始值"></BootstrapInput>
            </div>
            <div class="col-12 col-sm-12">
                <BootstrapInput  @bind-Value="@context.ClacuateFormula" Placeholder="变量公式" />
            </div>
            <div class="col-12 col-sm-6">
                <Switch @bind-Value="@context.IsRecord" Placeholder="是否记录" OnText="记录" OffText="不记录"></Switch>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInputNumber @bind-Value="@context.RecordCycle" Placeholder="记录周期"></BootstrapInputNumber>
            </div>
            <div class="col-12 col-sm-12">
                <Dropdown @bind-Value="@context.AlarmSetting" Placeholder="报警设定"></Dropdown>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInputNumber @bind-Value="@context.HighAlarmSet" Placeholder="高报警"></BootstrapInputNumber>
            </div>
            <div class="col-12 col-sm-6">
                <BootstrapInputNumber @bind-Value="@context.LowAlarmSet" Placeholder="低报警"></BootstrapInputNumber>
            </div>
        </div>
    </EditTemplate>
</Table>

<div class="row">
    <div class="col-12 col-sm-6">
        <Toggle Value="@IsExeclMode" ValueChanged="@OnEditModeChanged" OnText="Excel模式开启" OffText="Excel模式关闭" Color="Color.Primary" />
    </div>
</div>
